<?php
class DtupModel extends Action{
	//test
	//
	//公版
	public function getdtuplsbydtupqyqqno($dtupqyqqno){
		$info=collectinfo(__METHOD__,'$dtupqyqqno',array($dtupqyqqno));
		$dtup=M('dtup');
		$dtupls=$dtup->where("dtupqyqqno='".$dtupqyqqno."'")->select();
		return createarrok('ok',$dtupls,'',$info);
	}

	//公版
	public function add($dt){
		$info=collectinfo(__METHOD__,'$dt',array($dt));
				
		$dtup=M('dtup');
		$dtup->data($dt)->add();

		return createarrok('ok',$data,'',$info);
	}

	##########
	public function doupdate($all){
		$info=collectinfo(__METHOD__,'$all',array($all));
		if(isset($all)===false){return createarrerr('error_code','all 不能为空',$info);}//防止NULL
		
		$get=$_GET;
		$mdmk=$all['mdmk'];
   		
   		$lowmdmk=strtolower($mdmk);
		$m=M($lowmdmk);
		$mid=$lowmdmk.'id';
		
		$id=$get[$mid];

		$get['dtuptiqutm']=tm();

		if($get['dtupusrqqno']||$get['dtupalipayno']){
			$get['dtupstat']=1;
		}else{
			$get['dtupstat']=0;
		}

		unset($get[$mid]);
		unset($get['_URL_']);

		if($id==0){
			$m->data($get)->add();
			$pattern=0;
		}else{
			$m->where($mid.'='.$id)->setField($get);
			$pattern=1;
		}
   		
		
		return createarrok('ok',$pattern,'',$info);
	}
	

} 
?>